package com.example.a2205_fx.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.a2205_fx.R;
import com.example.a2205_fx.entity.VideoEntity;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import java.util.List;

public class VideoAdapter extends BaseMultiItemQuickAdapter<VideoEntity.DataBean, BaseViewHolder> {
    public VideoAdapter(@Nullable List<VideoEntity.DataBean> data) {
        super(data);
        addItemType(0, R.layout.item_video_home);
        addItemType(1, R.layout.item_video_home);
        addItemType(2, R.layout.item_video_home);
        addItemType(5, R.layout.item_video_home);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, VideoEntity.DataBean bean) {
        switch (bean.getItemType()){
            case 0:
            case 1:
            case 2:
            case 5:
                StandardGSYVideoPlayer gsy = holder.findView(R.id.gsy);
                gsy.setUp(bean.getVideopath(),true,"");
                gsy.getBackButton().setVisibility(View.GONE);
                gsy.startPlayLogic();
                //横屏的设置
                gsy.setLockLand(true);
                gsy.setShowFullAnimation(true);
                gsy.setAutoFullWithSize(false);
                //更改图片
                ImageView ivXihuan = holder.findView(R.id.iv_xihuan);
                ImageView ivUser = holder.findView(R.id.iv_user);
                if(bean.getDianzan()==1){
                    ivXihuan.setImageResource(R.drawable.ic_xihuanred);
                }else{
                    ivXihuan.setImageResource(R.drawable.ic_xihuan);
                }
                Glide.with(getContext()).load(bean.getHeadpath()).into(ivUser);
                //更改文字
                holder.setText(R.id.tv_caption,bean.getCaption());
                holder.setText(R.id.tv_user,bean.getAuthname());

                break;
        }

    }
}
